<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>渠道列表</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="__PUBLIC__/admin/favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.css" rel="stylesheet">
</head>
<include file="Admin@Index:cache" />
<body class="gray-bg contacts">
<style>
    .table-hover>tbody>tr>td{
        height:4rem;
    }
    .input1 {
        height: 31px;
        padding: 6px 12px;
        font-size: 14px;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
    }
</style>
<div class="wrapper wrapper-content animated fadeInRight" oncopy="copyval()">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>渠道统计</h5>
                </div>
                <div class="ibox-content">
                    <div class="col-sm-12" style="margin-bottom: 1rem">
                        <form role="form" action="__SELF__" method="get">




                            <div class="form-group">
                                <!--<button class="btn btn-sm btn-info m-t-n-xs" type="button" onclick="search1(1)"><strong>今日</strong></button>-->
                                <!--<button class="btn btn-sm btn-info m-t-n-xs" type="button" onclick="search1(2)"><strong>本周</strong></button>-->
                                <!--<button class="btn btn-sm btn-info m-t-n-xs" type="button" onclick="search1(3)"><strong>本月</strong></button>-->
                                <!--<button class="btn btn-sm btn-info m-t-n-xs" type="button" onclick="search1(4)"><strong>本年</strong></button>-->
                                <div class="layui-inline" style="display: inline-block;">
                                    <input class="input1" style="height: 2.5rem;" class="laydate-icon" placeholder="起始时间" id="start" name="<{$search.start}>">
                                    <input class="input1" style="height: 2.5rem;" class="laydate-icon" placeholder="截止时间" id="end" name="<{$search.end}>">
                                </div>
                               <button class="btn btn-sm btn-primary m-t-n-xs" type="button" onclick="search1(5)"><strong>查询</strong></button>
                            </div>
                        </form>
                    </div>
                    <br>
                    <table class="table table-striped table-hover">
                        <tbody>
                        <tr>
                            <th>渠道名</th>
                            <th>注册人数</th>
                            <th>认证数量</th>
                            <th>借款用户数</th>
                            <th>借款订单数</th>
                        </tr>
                        <foreach name="list" item="list">
                            <tr>
                                <td><{$list.channel_name}></td>
                                <td><{$list.register}></td>
                                <td><{$list.cert}></td>
                                <td><{$list.borrow_user}></td>
                                <td><{$list.borrow_order}></td>
                            </tr>
                        </foreach>
                        </tbody>
                    </table>
                    <ul class="pagination">
                        <if condition="$tol gt 10">
                            <{$fpage}>
                        </if>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/admin/js/layer/layer.js"></script>
<script src="__PUBLIC__/admin/js/layui/layui.js"></script>
<script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>
<script src="__PUBLIC__/admin/js/plugins/fancybox/jquery.fancybox.js"></script>
<script>
    function copyval() {
//        event.returnValue = false;
        var content = window.getSelection().toString();
        $.post('__MODULE__/Mypublic/copy_all', {content:content}, function (data) {
            if (data.code == '1001') {
            } else {
                console.log(data);
            }
        });
    }

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        var start = {
            choose:function(dates){
                end.min = dates; //开始日选好后，重置结束日的最小日期
                end.start = dates; //将结束日的初始值设定为开始日
            }
        };
        var end = {
            choose:function(dates){
                start.max = dates; //结束日选好后，重置开始日的最大日期
            }
        };

        document.getElementById('start').onclick = function(){
            start.elem = this;
            laydate(start);
        }
        document.getElementById('end').onclick = function(){
            end.elem = this;
            laydate(end);
        }
    });

    function search1(n) {
        var date = new Date();
        var start='';
        var end='';
        switch (n){
            case 1:
                end=start=date.getFullYear() + '-' + (date.getMonth() + 1 )+ '-' + date.getDate();
                break;
            case 2:
                start=getWeekStartAndEnd(0)[0];
                end=getWeekStartAndEnd(0)[1];
                break;
            case 3:
                start=getMonthStartAndEnd(0)[0];
                end=getMonthStartAndEnd(0)[1];
                break;
            case 4:
                start=date.getFullYear()+"-01-01";
                end=date.getFullYear()+"-12-31";
                break;
            case 5:
                start=$('#start').val();
                end=$('#end').val();
                if(start=="" || end=="" ){
                    layer.msg('起止时间不能为空',{icon:5,time:2000});
                    return false;
                }
                break;
        }
        window.location.href='__MODULE__/Operate/cpa_statistics?start='+start+'&end='+end;

    }
    //获取当前日期yy-mm-dd
    //date 为时间对象
    function getDateStr3(date) {
        var year = "";
        var month = "";
        var day = "";
        var now = date;
        year = ""+now.getFullYear();
        if((now.getMonth()+1)<10){
            month = "0"+(now.getMonth()+1);
        }else{
            month = ""+(now.getMonth()+1);
        }
        if((now.getDate())<10){
            day = "0"+(now.getDate());
        }else{
            day = ""+(now.getDate());
        }
        return year+"-"+month+"-"+day;
    }
    /**
     * 获得相对当前周AddWeekCount个周的起止日期
     * AddWeekCount为0代表当前周   为-1代表上一个周   为1代表下一个周以此类推
     * **/
    function getWeekStartAndEnd(AddWeekCount) {
        //起止日期数组
        var startStop = new Array();
        //一天的毫秒数
        var millisecond = 1000 * 60 * 60 * 24;
        //获取当前时间
        var currentDate = new Date();
        //相对于当前日期AddWeekCount个周的日期
        currentDate = new Date(currentDate.getTime() + (millisecond * 7*AddWeekCount));
        //返回date是一周中的某一天
        var week = currentDate.getDay();
        //返回date是一个月中的某一天
        var month = currentDate.getDate();
        //减去的天数
        var minusDay = week != 0 ? week - 1 : 6;
        //获得当前周的第一天
        var currentWeekFirstDay = new Date(currentDate.getTime() - (millisecond * minusDay));
        //获得当前周的最后一天
        var currentWeekLastDay = new Date(currentWeekFirstDay.getTime() + (millisecond * 6));
        //添加至数组
        startStop.push(getDateStr3(currentWeekFirstDay));
        startStop.push(getDateStr3(currentWeekLastDay));

        return startStop;
    }
    /**
     * 获得相对当月AddMonthCount个月的起止日期
     * AddMonthCount为0 代表当月 为-1代表上一个月  为1代表下一个月 以此类推
     * ***/
    function getMonthStartAndEnd(AddMonthCount) {
        //起止日期数组
        var startStop = new Array();
        //获取当前时间
        var currentDate = new Date();
        var month=currentDate.getMonth()+AddMonthCount;
        if(month<0){
            var n = parseInt((-month)/12);
            month += n*12;
            currentDate.setFullYear(currentDate.getFullYear()-n);
        }
        currentDate = new Date(currentDate.setMonth(month));
        //获得当前月份0-11
        var currentMonth = currentDate.getMonth();
        //获得当前年份4位年
        var currentYear = currentDate.getFullYear();
        //获得上一个月的第一天
        var currentMonthFirstDay = new Date(currentYear, currentMonth,1);
        //获得上一月的最后一天
        var currentMonthLastDay = new Date(currentYear, currentMonth+1, 0);
        //添加至数组
        startStop.push(getDateStr3(currentMonthFirstDay));
        startStop.push(getDateStr3(currentMonthLastDay));
        //返回
        return startStop;
    }


</script>


</body>

</html>
